package com.gitee.hermer.engine.jars.core.context;

import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

import com.gitee.hermer.boot.jee.commons.bean.utils.BeanLocator;
import com.gitee.hermer.boot.jee.commons.reflect.ClassUtils;
import com.gitee.hermer.boot.jee.commons.verify.Assert;
import com.gitee.hermer.engine.jars.core.context.envs.IEngineAppContextEnvironment;
import com.gitee.hermer.engine.jars.core.domain.EngineConstant;

@Component
public class EngineRootApplicationContextRefreshHandle  implements ApplicationListener<ContextRefreshedEvent> {

	@Override
	public void onApplicationEvent(ContextRefreshedEvent event) {
		Assert.isTrue(!(ClassUtils.isAssignable(EngineConstant.CLASS_ENGINE_APP_CLASS_LOADER, event.getApplicationContext().getClassLoader().getClass())));
		BeanLocator.setSpringContext(event.getApplicationContext());
	}

}
